(function(){
  let hash = window.location.hash;
  let search = window.location.search;
  let url = window.location.origin+window.location.pathname;

  if(hash.length>0){
    let hashInfo = {};
    hash = hash.substring(1);

    let hashes = hash.split('&');
    hashes.forEach(function(value, index, array) {
      let param = value.split("=");
      if(param.length==2){
        hashInfo[param[0]]=param[1];
      }
    });
    hashInfo.origin = hash;
    hashInfo = JSON.stringify(hashInfo);
    var session = window.sessionStorage;
    session.setItem("hashInfo",hashInfo);
  }

  if(search.length>0){
    let paramInfo = {};
    search = search.substring(1);
    let params = search.split('&');
    params.forEach(function(value, index, array) {
      let param = value.split("=");
      if(param.length == 2){
        paramInfo[param[0]]=param[1];
      }
    });
    paramInfo.origin = search;
    paramInfo = JSON.stringify(paramInfo);
    var session = window.sessionStorage;
    session.setItem("paramInfo",paramInfo);
  }

  if(hash.length>0||search.length>0){
    window.location.replace(url);
  }else {
    if(!window.global){
      window.global = {};
    }
    require('./startup.js');
  }
})();


